package test.test1;



import java.util.Calendar;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import test.test1.mybatis.pojo.Question;
import test.test1.mybatis.pojo.Answer;
import test.test1.mybatis.pojo.MyService;
import test.test1.mybatis.pojo.MyService2;
import test.test1.mybatis.pojo.Player;

/**
 * Hello world!
 *
 */
public class SpringBeanConstruct 
{
    public static void main( String[] args )
    {
    	
//    	springDemo();
//    	springClassDemo();
//    	springClassDemo2();
//    	springSingle();
    	springprototype();
    }
    
    
    
    private static void springDemo() {
    	ApplicationContext context =
    		    new ClassPathXmlApplicationContext("springBeanConstruct.xml");
    	Answer q = context.getBean("answer", Answer.class);
    	System.out.println(q);
    	
    }
 
    
    private static void springClassDemo() {
    	ApplicationContext context =
    		    new ClassPathXmlApplicationContext("springBeanConstruct.xml");
    	Player player = context.getBean("exampleBean", Player.class);
    	System.out.println(player);
    }
    
    private static void springClassDemo2() {
    	ApplicationContext context =
    		    new ClassPathXmlApplicationContext("springBeanConstruct.xml");
    	//context.getBean("testNoEmpty");
    	//Calendar cal = new Calendar();
    	MyService cal = (MyService) context.getBean("service");
    	System.out.println(cal);
    }
    
    private static void springSingle() {
    	ApplicationContext context =
    		    new ClassPathXmlApplicationContext("springBeanConstruct.xml");
    	//context.getBean("testNoEmpty");
    	//Calendar cal = new Calendar();
    	MyService cal = (MyService) context.getBean("service");
    	System.out.println(cal);
    	
    	MyService cal1 = (MyService) context.getBean("service");
    	System.out.println(cal1);
    	
    	MyService cal2 = (MyService) context.getBean("service");
    	System.out.println(cal2);
    }
    
    private static void springprototype() {
    	ApplicationContext context =
    		    new ClassPathXmlApplicationContext("springBeanConstruct.xml");
    	//context.getBean("testNoEmpty");
    	//Calendar cal = new Calendar();
    	MyService2 cal = (MyService2) context.getBean("proService");
    	System.out.println(cal);
    	
    	MyService2 cal1 = (MyService2) context.getBean("proService");
    	System.out.println(cal1);
    	
    	MyService2 cal2 = (MyService2) context.getBean("proService");
    	System.out.println(cal2);
    }
}
